package test;

import java.util.Date;

public class Car {
    private Fee fee;

    public static void main(String[] args) throws Exception {
        // 起步价3公里(<=3)，白天（早6点到晚6点，下同）14元，晚上（晚6点到早6点，下同）18元
        // 3~10公里(>3且<=10)，白天每公里2.5元，晚上每公里3元
        // 10公里以上(>10)，白天每公里3.5元，晚上每公里4.7元；

        Fee fee6 = new Fee(10, 10, 4.7, 18, 6, 1);
        Fee fee5 = new Fee(3, 10, 3, 18, 6, 1, fee6);
        Fee fee4 = new Fee(0, 3, 18, 18, 6, 0, fee5);
        Fee fee3 = new Fee(10, 10, 3.5, 6, 18, 1, fee4);
        Fee fee2 = new Fee(3, 10, 2.5, 6, 18, 1, fee3);
        Fee fee1 = new Fee(0, 3, 14, 6, 18, 0, fee2);

        Car car = new Car(fee1);
        System.out.println(car.getSum(new Date(), 11));

        //同理的话，乙型车也按照上面同样的Fee创建 ，维护的话 ，只维护Fee这个对象
    }

    public double getSum(Date time, double distance) {
        return fee.getFee(time, distance, 0);
    }

    public Car(Fee fee) {
        this.fee = fee;
    }

    public Fee getFee() {
        return fee;
    }

    public void setFee(Fee fee) {
        this.fee = fee;
    }

}
